package cn.myjerry.others.que;

import java.util.ArrayDeque;
import java.util.Queue;

/**
 * 模拟银行存款业务
 * @author Jerry
 *
 */
public class Demo01 {
	public static void main(String[] args) {
		Queue<Request> que = new ArrayDeque<Request>();
		//模拟排队情况
		for(int i=0;i<10;i++) {
			final int m = i;
			que.offer(new Request() {
				
				@Override
				public void deposit() {
					System.out.println("第"+ m +"个人排队，存款" + (Math.random()*10000));
				}
			});
		}
		dealith(que);
	}
	//处理业务
	public static void dealith(Queue<Request> que){
		Request req = null;
		while(null != (req = que.poll())) {
			req.deposit();
		}
	}
}
interface Request{
	//存款
	void deposit();
}